package com.bootdo.analyze.controller;

import com.bootdo.analyze.domain.ClientSellAIDO;
import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import com.bootdo.settingDemo.domain.EmployeeinfoDO;
import com.bootdo.settingDemo.service.EmployeeinfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 生成编号
 */
@Controller
@RequestMapping("/analyze/codegeneration")
public class CodeGeneration {
    @Autowired
    private EmployeeinfoService employeeinfoService;

    @ResponseBody
    @GetMapping("/employeecode")
    public String employeeCode(){
        //查询列表数据
        Map<String, Object> params = new HashMap<String, Object>();
        List<EmployeeinfoDO> goodsList = employeeinfoService.list(params);
        int total = goodsList.size();
        String number = "";
        if (total>0){
            long total1 =(long)(total+99);
            String n = employeeinfoService.get(total1).getUsername();
            int intNumber = Integer.parseInt(n.substring(3));
            intNumber++;
            number = String.valueOf(intNumber);
            for (int i = 0; i < 3; i++){
                number = number.length() < 3 ? "0" + number : number;
            }
            number = "YG00"  + number;
        }else {
            number = "YG00"  + "001";
        }

        return number;
    }
}
